package syn;

import java.util.ArrayList;
import java.util.List;

public class TestListAdd implements Runnable {


	public static void main(String[] args) throws InterruptedException {
		List list = new ArrayList();
		for (int i = 0; i < 10000; i++) {
			Thread a = new Thread(() -> {
				synchronized (list) {
					list.add(Thread.currentThread().getName());
				}
				System.out.println(list.size());
			});
			a.start();
		}
		Thread.sleep(3000);
		System.out.println("=====================" + list.size());
	}

	@Override
	public void run() {

	}
}
